/**
 * JFunny - A funny programming language
 * Copyright (C) 2013  fanguangping
 * Any problem email me: fguangping@gmail.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 **/
package org.jfunny.core.ds;

import java.util.ArrayList;
import java.util.List;

/**
 * 参数节点，表示 { 与 } 括起来的部分，是树干
 * 
 * @author fanguangping
 *
 */
public class Arg implements Statement {
	private ArrayList<Statement> statements = new ArrayList<Statement>();

	public boolean addChild(Statement statement) {
		return statements.add(statement);
	}

	public boolean removeChild(Statement statement) {
		return statements.remove(statement);
	}

	public List<Statement> getChildren() {
		return statements;
	}

	public void setChildren(ArrayList<Statement> statements) {
		this.statements = statements;
	}

	public String toString() {
		String str = "{";

		Statement last = null;
		for (Statement s : statements) {
			if (last != null && last instanceof Symbol && s instanceof Symbol) {
				str += " ";
			}
			str += s;
			last = s;
		}
		str += "}";

		return str;
	}
}
